package com.naiterui.ehp.bs.payment.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.collect.Maps;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.payment.service.IOrderSnService;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 订单号生成控制器
 *
 * @date 2017年09月25日
 * @since 1.0.0
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/order/sn")
@Api(value = "订单号生成接口", description = "订单号生成接口")
public class OrderSnController {

    private final IOrderSnService orderSnService;

    /**
     * 获取订单号
     *
     * @param orderType 订单号类型
     *
     * @return 生成的订单号
     */
    @GetMapping("/{orderType}")
    @ApiOperation(value = "订单号生成")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderType", value = "订单号类型 1:个性自定义收费 2:图文咨询收费 3:患者打赏 4:健康检查 5:视频预约", required = true,
            dataType = "int", paramType = "path")})
    public ResponseVO<Map<String, String>> getTradeSn(@PathVariable Integer orderType) {
        log.info("订单号生成 orderType:{}", orderType);
        String orderSn = this.orderSnService.getPayInfoTradeSn(orderType);
        Map<String, String> orderSnMap = Maps.newHashMap();
        orderSnMap.put("orderSn", orderSn);
        return PublicService.returnResponseVO(orderSnMap);
    }

}
